// 本文件由自动工具 proto.py 自动生成，请勿修改
// filename test1_csbuf.ts
// package test


// message Head
export class Head {
	protoid = 1000,
	a: number = 0;
	b: string = "";


Marshal(writer: any) {
	writer.setUint32(this.a, 1)
	writer.setString(this.b, 2)
}

Unmarshal(reader: any) {
	this.a = reader.getUint32(1)
	this.b = reader.getString(2)
}
}

// message Test1
export class Test1 {
	protoid = 2001,
	a_t1: number = 0;
	at_2: number = 0;
	at3_: string = "";
	t4: number[] = [];
	t5: string[] = [];
	t6 = new Head();
	t7: Head[] = [];


Marshal(writer: any) {
	writer.setUint8(this.a_t1, 1)
	writer.setUint32(this.at_2, 2)
	writer.setString(this.at3_, 3)
	writer.setArray(this.t4.length, 4)
	for (let v of this.t4) {
		writer.setUint32(v, 0)
	}
	writer.setArray(this.t5.length, 5)
	for (let v of this.t5) {
		writer.setString(v, 0)
	}
	writer.setMessage(6)
	this.t6.Marshal(writer)
	writer.endSetMessage()
	writer.setArray(this.t7.length, 7)
	for (let v of this.t7) {
		writer.setMessage(0)
		v:Marshal(writer)
		writer.endSetMessage()
	}
}

Unmarshal(reader: any) {
	this.a_t1 = reader.getUint8(1)
	this.at_2 = reader.getUint32(2)
	this.at3_ = reader.getString(3)
	let count = reader.getArray(4)
	for (let i=1; i < count; i++) {
		this.t4.push(reader.getUint32(0)))
	}
	let count = reader.getArray(5)
	for (let i=1; i < count; i++) {
		this.t5.push(reader.getString(0)))
	}
	reader.getMessage(6)
	this.t6.Unmarshal(reader)
	reader.endGetMessage()
	let count = reader.getArray(7)
	for (let i=1; i < count; i++) {
		let msg = new Head()
		reader.getMessage(0)
		msg.Unmarshal(reader)
		reader.endGetMessage()
		this.t7.push( msg)
	}
}
}

// message Test2
export class Test2 {
	protoid = 2002,
	a_t1: number = 0;
	at_2: number = 0;
	at3_: string = "";
	t6 = new Head();
	t7: Head[] = [];


Marshal(writer: any) {
	writer.setUint8(this.a_t1, 1)
	writer.setUint32(this.at_2, 2)
	writer.setString(this.at3_, 3)
	writer.setMessage(6)
	this.t6.Marshal(writer)
	writer.endSetMessage()
	writer.setArray(this.t7.length, 7)
	for (let v of this.t7) {
		writer.setMessage(0)
		v:Marshal(writer)
		writer.endSetMessage()
	}
}

Unmarshal(reader: any) {
	this.a_t1 = reader.getUint8(1)
	this.at_2 = reader.getUint32(2)
	this.at3_ = reader.getString(3)
	reader.getMessage(6)
	this.t6.Unmarshal(reader)
	reader.endGetMessage()
	let count = reader.getArray(7)
	for (let i=1; i < count; i++) {
		let msg = new Head()
		reader.getMessage(0)
		msg.Unmarshal(reader)
		reader.endGetMessage()
		this.t7.push( msg)
	}
}
}

return test
